package com.ruoyi.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.domain.AppActivities;
import com.ruoyi.app.service.IAppActivitiesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 校友会活动（无物理外键，通过业务逻辑维护关联）Controller
 * 
 * @author ruoyi
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/app/activities")
public class AppActivitiesController extends BaseController
{
    @Autowired
    private IAppActivitiesService appActivitiesService;

    /**
     * 查询校友会活动（无物理外键，通过业务逻辑维护关联）列表
     */
    @PreAuthorize("@ss.hasPermi('app:activities:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppActivities appActivities)
    {
        startPage();
        List<AppActivities> list = appActivitiesService.selectAppActivitiesList(appActivities);
        return getDataTable(list);
    }

    /**
     * 导出校友会活动（无物理外键，通过业务逻辑维护关联）列表
     */
    @PreAuthorize("@ss.hasPermi('app:activities:export')")
    @Log(title = "校友会活动（无物理外键，通过业务逻辑维护关联）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppActivities appActivities)
    {
        List<AppActivities> list = appActivitiesService.selectAppActivitiesList(appActivities);
        ExcelUtil<AppActivities> util = new ExcelUtil<AppActivities>(AppActivities.class);
        util.exportExcel(response, list, "校友会活动（无物理外键，通过业务逻辑维护关联）数据");
    }

    /**
     * 获取校友会活动（无物理外键，通过业务逻辑维护关联）详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:activities:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId)
    {
        return success(appActivitiesService.selectAppActivitiesByActivityId(activityId));
    }

    /**
     * 新增校友会活动（无物理外键，通过业务逻辑维护关联）
     */
    @PreAuthorize("@ss.hasPermi('app:activities:add')")
    @Log(title = "校友会活动（无物理外键，通过业务逻辑维护关联）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppActivities appActivities)
    {
        return toAjax(appActivitiesService.insertAppActivities(appActivities));
    }

    /**
     * 修改校友会活动（无物理外键，通过业务逻辑维护关联）
     */
    @PreAuthorize("@ss.hasPermi('app:activities:edit')")
    @Log(title = "校友会活动（无物理外键，通过业务逻辑维护关联）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppActivities appActivities)
    {
        return toAjax(appActivitiesService.updateAppActivities(appActivities));
    }

    /**
     * 删除校友会活动（无物理外键，通过业务逻辑维护关联）
     */
    @PreAuthorize("@ss.hasPermi('app:activities:remove')")
    @Log(title = "校友会活动（无物理外键，通过业务逻辑维护关联）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(appActivitiesService.deleteAppActivitiesByActivityIds(activityIds));
    }
}
